package servletController;

import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServlet;

import servletController.RequestData;

@SuppressWarnings("unused")
public class ControllerHelper extends HelperBase {
	
	RequestData data = new RequestData();
	
	public ControllerHelper(HttpServletRequest request, HttpServletResponse response) {
		super(request, response);
	}

	public Object getData(){
		return data;
	}
                           
	protected void doGet() throws IOException, ServletException {
		request.getSession().setAttribute("helper", this);

		data.setHobby(request.getParameter("hobby"));
		data.setAversion(request.getParameter("aversion"));

		String address;

		if (request.getParameter("processButton") != null) {
			address = "Process.jsp";
		} else if (request.getParameter("confirmButton") != null) {
			address = "Confirm.jsp";
		} else {
			address = "Edit.jsp";
		}

		RequestDispatcher dispatcher = request.getRequestDispatcher(address);
		dispatcher.forward(request, response);
	}

}
